package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: yang
 * Date: 2022-05-19
 * Time: 19:12
 */
public class AddOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入书名：");
        String name = scan.nextLine();
        System.out.println("请输入作者名：");
        String author = scan.nextLine();
        System.out.println("请输入价格：");
        double price = scan.nextDouble();
        System.out.println("请输入种类：");
        String type = scan.nextLine();
        Book book = new Book(name, author, price,type);
        bookList.setBook(bookList.getUsedSize(), book);
        bookList.setUsedSize(bookList.getUsedSize()+1);
        System.out.println("添加成功！");
    }
}
